package com.xinli.xinlifm.view.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.widget.TextView;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.xinli.xinlifm.R;
import com.xinli.xinlifm.http.bean.DianTaiBean;
import com.xinli.xinlifm.mvp.iview.MvpView;
import com.xinli.xinlifm.mvp.model.SuperModel;
import com.xinli.xinlifm.view.adapter.DiantaiAdapter;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.util.ArrayList;
import java.util.List;

public class DianTaiActivity extends AppCompatActivity implements MvpView<DianTaiBean> {
    public SuperModel mModel;
    public TextView diantai_title;
    public RecyclerView diantai_recyclerview;
    private List<Object> objects = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Fresco.initialize(this);
        setContentView(R.layout.activity_dian_tai);
        diantai_title = (TextView) findViewById(R.id.diantai_title);
        diantai_recyclerview = (RecyclerView) findViewById(R.id.diantai_recyclerview);
        diantai_title.setText("发现主播");
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        diantai_recyclerview.setLayoutManager(linearLayoutManager);
        EventBus.getDefault().register(this);
        mModel = new SuperModel();
        mModel.getDianTaiData("046b6a2a43dc6ff6e770255f57328f89");
    }

    @Subscribe
    @Override
    public void showView(DianTaiBean data) {
        Log.e("DianTaiActivity", "showView: " + data.getData().getTuijian().get(0).getTitle());
        EventBus.getDefault().unregister(this);
        objects.add(data.getData().getTuijian());
        objects.add(data.getData().getNewlist());
        objects.add(data.getData().getHotlist());
        Log.e("自定义标签", "类名==DianTaiActivity" + "方法名==showView=====:" + objects);
        diantai_recyclerview.setAdapter(new DiantaiAdapter(this,objects));
    }
}
